#!/bin/bash

# 在 BUILD_ABBREVIATIONS 部分后添加配置管理器插件的条件编译
sed -i '/if BUILD_ABBREVIATIONS/,/endif/ a\
if BUILD_CONFIGMANAGER\
MAYBE_CONFIGMANAGER=configmanager\
endif\
if BUILD_CONFIGMANAGER_COMMON\
MAYBE_CONFIGMANAGER_COMMON=configmanager_common\
endif\
if BUILD_CONFIGMANAGER_IMPORTERS\
MAYBE_CONFIGMANAGER_IMPORTERS=configmanager_importers\
endif\
if BUILD_CONFIGMANAGER_EXPORTERS\
MAYBE_CONFIGMANAGER_EXPORTERS=configmanager_exporters\
endif' plugins/Makefile.am

# 在 SUBDIRS 中添加新的插件
sed -i 's/$(MAYBE_ABBREVIATIONS) \\/$(MAYBE_ABBREVIATIONS) \\\n                $(MAYBE_CONFIGMANAGER) \\\n                $(MAYBE_CONFIGMANAGER_COMMON) \\\n                $(MAYBE_CONFIGMANAGER_IMPORTERS) \\\n                $(MAYBE_CONFIGMANAGER_EXPORTERS) \\/' plugins/Makefile.am

# 在 DIST_SUBDIRS 中添加新的插件目录
sed -i 's/xpmanifest \\/xpmanifest \\\n                configmanager \\\n                configmanager_common \\\n                configmanager_importers \\\n                configmanager_exporters \\/' plugins/Makefile.am

echo "plugins/Makefile.am 更新完成"
